Xbasic

{CAN_EXIT}

Syntax

{CAN_EXIT= Event_Value }

Arguments

Event_ValueCharacter

A value for a_dlg_button that the event handlers in the %code% section to respond to.

Description

Allows you to trap an attempt by the user to close a Xdialog box.

Discussion

The {CAN_EXIT} command allows you to trap an attempt by the user to close a Xdialog box by clicking on the (close button) at the upper right corner of the dialog box. This allows you to write code that tests if the user can close the dialog box. If the necessary conditions exist, then the dialog can be closed. If not, you can prevent the dialog from closing.

The first example shows how you might use this command in a modeless Xdialog. The second example shows how you might use the command in a modal Xdialog.

Example

ui_modeless_dlg_box("Demo",<<%dlg%
{can_exit=exit}
This is a modeless Xdialog.;
Try to close the dialog by clicking on the X in the title bar.;
<Close>;
%dlg%,<<%code%
if a_dlg_button = "close" then
    ui_modeless_dlg_close("demo")
end if
if a_dlg_button = "exit" then
    q = ui_msg_box("Warning", "Are you sure that you want to exit the dialog?", ui_yes_no)
    if q = ui_yes_selected then
        ui_modeless_dlg_close("demo")
    end if
    'if the user selects No, then do nothing - the dialog will remain open
end if
%code%)
ui_dlg_box("Demo",<<%dlg%
{can_exit=exit}
This is a modal Xdialog.;
Try to close the dialog by clicking on the X in the title bar.;
<Close>;
%dlg%,<<%code%
if a_dlg_button = "close" then
    'do nothing - the dialog will close
end if
if a_dlg_button = "exit" then
    q = ui_msg_box("Warning", "Are you sure that you want to exit the dialog?", ui_yes_no)
    if q = ui_yes_selected then
        'do nothing - the dialog will close
    else
        a_dlg_button = "" 'setting a_dlg_button to NULL keeps the modal dialog open
    end if
end if
%code%)

Limitations

Desktop applications only

See Also